
	var custName;
	var custIDcardNo;
	var custTele;
	var loanQuota;
	var loanStagId;
	var purposeId;
	var getPageNum;

$(function(){
	//页面加载列表
	loadlist();
	
	//点击查询获取文本框值
	$("#btn_submit_look").click(function(){
		custName=$("[name=custName]").val();
		custIDcardNo=$("[name=custIDcardNo]").val();
		custTele=$("[name=custTele]").val();
		loanQuota=$("[name=loanQuota]").val();
		loanStagId=$("[name=loanStagId]").val();
		purposeId=$("[name=purposeId]").val();
		loadlist();
	});
	
	//分页跳转到第几页
	$("#btnpage").click(function(){
		getPageNum=$("#pageform").find("[name=pagejump]").val();
		loadlist();//调用页面加载列表
	});
	
	$("#btn_save_loanApp").click(function(){
		var boot=document.getElementById("check_ace");
		var custName=$("#loanMiwe").find("#custName").html();
		if(boot.checked){
			if(confirm("确定要提交您的审查过的数据吗?")){
				var formData=new FormData(document.querySelector("#checkFrom"));
				var  keys=formData.keys(); 
				var key; 
				while(!(key=keys.next()).done){
				 	 console.log(key.value); 
					 console.log(formData.get(key.value)); 
				}
				$.ajax({
					type : "POST",
					url : "/updateloanType",
					data : formData,
					async : false,
					clearForm : true,
					clearForm : true,
					contentType : false,
					processData : false,
					dataType : "json",
					success : function(data) {//请求成功时处理
						 if(data.upadd==true){
							 alert("【"+custName+"】 客戶的贷款申请"+boot.value);
							 window.location.reload();
						 }else{
							 alert("【"+custName+"】 客戶的贷款申请打回，未审查"); 
						 }
					 },
					 error : function(data){
						 alert("【"+custName+"】 的贷款申请，无法审查，请求出现错误");
					 }
				 });
			}
		}else{
			alert("请勾选起是否通过审查，再进行提交");
		}
	});
	
	 
});
/**
 * 加載列表信息
 * @returns
 */
function loadlist(){
	$.ajax({
		type : "POST", //请求方式
		url : "/loanapplist",    //请求的url地址
		data : {custName: custName,
				custIDcardNo: custIDcardNo,
				custTele:custTele ,
				loanQuota:loanQuota,
				loanStagId:loanStagId,
				purposeId:purposeId,
				pageNum:getPageNum},    //参数值
	    dataType : "json",   //返回格式为json
	    success:function(date){	//请求成功时处理
	    	//清空列表
	    	$("#loanlist").html("");
	    	if(date.loanlist.length == 0){
	    		$("#loanlist").prepend("<tr th:class='loans_id'>" +
	    				"<td class='center red text-center' colspan='10'><strong>没有数据</strong></td>" +
	    		"</tr>");
	    	}
	    	//追加数据显示数据
	    	for (var i = 0; i < date.loanlist.length; i++) {
	    		$("#loanlist").prepend(
	    				"<tr class='loans_id_"+date.loanlist[i].loanId+"'>" +
	    					"<td><a class='loanId' href='#'>"+date.loanlist[i].loanId+"</a></td>" +
	    					"<td class='custName'>"+date.loanlist[i].customer.custName+"</td>" +
	    					"<td class='custIDcardNo'>"+date.loanlist[i].customer.custIDcardNo+"</td>" +
	    					"<td class='custTele'>"+date.loanlist[i].customer.custTele+"</td>" +
	    					"<td class='loanQuota'>"+date.loanlist[i].loanQuota+"</td>" +
	    					"<td class='stagByNumber'>"+date.loanlist[i].staging.stagByNumber+"</td>" +
	    					"<td class='hidden-480' id='purposeName'>"+date.loanlist[i].purpose.purposeName+"</td>" +
	    					"<td class='loanDate'>"+date.loanlist[i].loanDate+"</td>" +
	    					"<td class='hidden-480'>" +
	    						"<span class='label label-sm label-warning' id='type'>"+date.loanlist[i].loanType+"</span>"
	    					+"</td>" +
	    					"<td>" +
		    					"<div class='visible-md visible-lg hidden-sm hidden-xs action-buttons' id='chektd'>" +
			    					"<a href='#modal-table' value='"+date.loanlist[i].loanId+"'" +
			    							" role='button' class='green checkinfo' data-toggle='modal'>" +
			    						"<i class='icon-zoom-in bigger-130'></i>" +
			    					"</a>" +
			    					"<a class='green'  href='#' value='"+date.loanlist[i].loanId+"'>" +
			    						"<i class='icon-pencil bigger-130'></i>" +
			    					"</a>" +
		    					"</div>" +
		    					"<div style='display: none;'>" +
			    					"<span class='loanEmerContOne'>"+date.loanlist[i].loanEmerContOne+"</span>" +
			    					"<span class='loanTeleOne'>"+date.loanlist[i].loanTeleOne+"</span>" +
			    					"<span class='loanEmerContTwo'>"+date.loanlist[i].loanEmerContTwo+"</span>" +
			    					"<span class='loanTeleTwo'>"+date.loanlist[i].loanTeleTwo+"</span>" +
			    					"<span class='loanEmerContThree'>"+date.loanlist[i].loanEmerContThree+"</span>" +
			    					"<span class='loanTeleThree'>"+date.loanlist[i].loanTeleThree+"</span>" +
			    					"<span class='loanCardJustPath'>"+date.loanlist[i].loanCardJustPath+"</span>" +
			    					"<span class='loanCardBackPath'>"+date.loanlist[i].loanCardBackPath+"</span>" +
			    					"<span class='loanCardPath'>"+date.loanlist[i].loanCardPath+"</span>" +
		    					"</div>" +
		    					"<div class='visible-xs visible-sm hidden-md hidden-lg'>" +
		    						"<div class='inline position-relative'>" +
		    							"<button class='btn btn-minier btn-yellow dropdown-toggle' data-toggle='dropdown'>" +
		    								"<i class='icon-caret-down icon-only bigger-120'></i>" +
		    							"</button>" +
		    							"<ul class='dropdown-menu dropdown-only-icon dropdown-yellow pull-right dropdown-caret dropdown-close'>" +
		    								"<li>" +
		    									"<a href='#' class='tooltip-info' data-rel='tooltip' title='View' value='"+date.loanlist[i].loanId+"'>" +
		    										"<span class='blue'>" +
		    											"<i class='icon-zoom-in bigger-120'></i>" +
		    										"</span>" +
		    									"</a>" +
		    								"</li>" +
		    								"<li>" +
		    									"<a href='#' class='tooltip-success' data-rel='tooltip' title='Edit' value='"+date.loanlist[i].loanId+"'>" +
		    										"<span class='green'>" +
		    											"<i class='icon-edit bigger-120'></i>" +
		    										"</span>" +
		    									"</a>" +
		    								"</li>" +
					    				"</ul>" +
					    			"</div>" +
		    					"</div>" +
	    					"</td>" +
	    				"</tr>");
			}
	    	
	    	//分页操作
			/**
			  * 总页数 ="+getPages         
				总条数 ="+getTotal         
				下一页 ="+getNextPage      
				上一页 ="+getPrePage       
				当前页 ="+getPageNum       
				第一页 ="+getFirstPage     
				最后一页 ="+getLastPage     
				每页显示条数 ="+getPageSize   
				获取当前页信息 ="+getStartRow  
				分页后返回页面的数据 ="+getList   
			*/
	    	//总页数
	    	var getPages= date.pageinfo.pages;
	    	//每页显示条数
	    	var getPageSize=date.pageinfo.pageSize;
	    	//获取当前页信息
	    	getPageNum=date.pageinfo.pageNum;
			$("#pages").html(getPages);
			$("#pageSize").html(getPageSize);
			$("#page").html(getPageNum);
			
			
			if(getPageNum==1){
				$(".no-margin").find("#firstprev").attr("class","disabled");
				$(".no-margin").find("#prev").attr("class","disabled");
			}else{
				$(".no-margin").find("#firstprev").attr("class","");
				$(".no-margin").find("#prev").attr("class",""); 
			}
			//首页
			$('#firstprev').unbind('click').bind('click',function(){
				getPageNum=1;
				loadlist();//调用页面加载列表
			});
			//上一页
			$('#prev').unbind('click').bind('click',function(){
				getPageNum=date.pageinfo.prePage;
				loadlist();//调用页面加载列表
			});
			//下一页
			$('#next').unbind('click').bind('click',function(){
				getPageNum=date.pageinfo.nextPage;
				loadlist();//调用页面加载列表
			});
			//尾页
			$('#lastnext').unbind('click').bind('click',function(){
				getPageNum=date.pageinfo.lastPage;
				loadlist();//调用页面加载列表
			});
			
			//点击查看详细信息
			$(".checkinfo").click(function(){
				//获取点击时标签valve值
				var info=$(this).attr("value");
				checkinfo(info);
			});
	    }
	});
}
/**
 * 审查申请贷款详细信息
 * @param checkinfo
 * @returns
 */
function checkinfo(checkinfo){
	//获取tr标签的class
	var tr=$(".loans_id_"+checkinfo);
	//申请贷款编号
	$("#loanMiwe").find("#loanId").val(checkinfo);
	//申请人名称
	var custName=$(tr).find(".custName").html();
	$("#loanMiwe").find("#custName").html(custName);
	//身份证号
	$("#loanMiwe").find("#custIDcardNo").text($(tr).find(".custIDcardNo").html());
	//手机号码
	$("#loanMiwe").find("#custTele").text($(tr).find(".custTele").html());
	//联系人1
	$("#loanMiwe").find("#loanEmerContOne").text($(tr).find(".loanEmerContOne").html());
	//联系1
	$("#loanMiwe").find("#loanTeleOne").text($(tr).find(".loanTeleOne").html());
	//联系人2
	$("#loanMiwe").find("#loanEmerContTwo").text($(tr).find(".loanEmerContTwo").html());
	//联系2
	$("#loanMiwe").find("#loanTeleTwo").text($(tr).find(".loanTeleTwo").html());
	//联系人3
	$("#loanMiwe").find("#loanEmerContThree").text($(tr).find(".loanEmerContThree").html());
	//联系3
	$("#loanMiwe").find("#loanTeleThree").text($(tr).find(".loanTeleThree").html());
	//金额
	$("#loanMiwe").find("#loanQuota").text($(tr).find(".loanQuota").html());
	//期数
	$("#loanMiwe").find("#loanStagId").text($(tr).find(".stagByNumber").html()+"期");
	//身份证照正面
	$("#loanMiwe").find("#loanCardJustPath").text($(tr).find(".loanCardJustPath").html());
	//身份证照反面
	$("#loanMiwe").find("#loanCardBackPath").text($(tr).find(".loanCardBackPath").html());
	//本人手持身份证照片
	$("#loanMiwe").find("#loanCardPath").text($(tr).find(".loanCardPath").html());
	//申请贷款用途类型
	$("#loanMiwe").find("#purposeId").text($(tr).find("#purposeName").html());
	//申请时间
	$("#loanMiwe").find("#loanDate").text($(tr).find(".loanDate").html());
	//审查类型
	var type=$(tr).find("#type").html();
	$("#loanMiwe").find("#loanType").text(type);
	if(type=="已审查"){
		$("#btn_ces").find("#btn_save_loanApp").attr("disabled","disabled");
		$("#check_ace:checkbox").prop("checked", false).attr("disabled","disabled");
	}else{
		$("#btn_ces").find("#btn_save_loanApp").removeAttr("disabled");
		$("#check_ace:checkbox").prop("checked", false).removeAttr("disabled");
	}
}




